using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AXBC = Microsoft.Dynamics.BusinessConnectorNet;
using AXMD = Microsoft.Dynamics.Framework.Metadata.Ax;
using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;

namespace DynamicsAXPS
{
    [System.Management.Automation.Cmdlet("New", "AXUser")]
    public class New_AXUser : System.Management.Automation.PSCmdlet
    {
        [System.Management.Automation.Parameter(Position = 0, Mandatory = true)]
        public string ID;

        [System.Management.Automation.Parameter(Position = 1, Mandatory = true)]
        public string Name;

        [System.Management.Automation.Parameter(Position = 2, Mandatory = true)]
        public string Alias;

        [System.Management.Automation.Parameter(Position = 3, Mandatory = true)]
        public string Domain;

        [System.Management.Automation.Parameter(Position = 4, Mandatory = true)]
        public string Company;

        protected override void ProcessRecord()
        {
            var ax = new AXBC.Axapta();
            ax.Logon(null, null, null, null);
            string method = "CreateAXUser";
            string _class = "DynamicsAXPS";
            object[] parameters = new object[] { this.ID, this.Name, this.Alias, this.Domain, this.Company, 1, 0 };

            var retval = ax.CallStaticClassMethod(_class, method, parameters);
            this.WriteObject(retval);
            ax.Logoff();
        }
    }
}
